var upperboundary = 0;
var total = 0;
var show = 4;

function recycle(i) {
	return function (){
		$('#comment'+i).remove().css('display','none').prependTo('#items');
	};
}

function squeezeScroll(){
	var nextIndex = (upperboundary - 1);
	if(nextIndex < 0){
		nextIndex += total;
	}
	var lowerboundary = (upperboundary + show - 1);
	if (lowerboundary >= total) {
		lowerboundary = lowerboundary - total;
	}

	$('#comment'+nextIndex).slideDown(1000,recycle(lowerboundary));

	upperboundary = nextIndex;
	setTimeout("squeezeScroll()",4000);
}

$(document).ready(
	function(){
		var items = $('#comments').children('#items').first().children();
		total = items.size();
		var border = total-show;
		upperboundary = border;
		$(items).each(function(i){
			if(i < border){
				$(this).css('display','none');
			} else {
				$(this).css('display','block');
			}
		});
		if(total > show){
			setTimeout("squeezeScroll()",4000);
		}
	}
);
